package com.candy.control;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginController implements Controller {
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        System.out.println("服务器接收到您发送的请求");
//        接收前台表单传过来的username属性的值
         String username= request.getParameter("username");
//         接收前台表单传过来的userpwd属性的值
       String userpwd= request.getParameter("userpwd");
        System.out.println("用户名："+username);
        System.out.println("密码："+userpwd);
        ModelAndView mv=new ModelAndView();
//    设置返回视图的名字： 视图解析器会将视图的前缀后缀拼接好后返回：
//    WEB-INF/pages/welcome.jsp
        mv.setViewName("welcome");
//        在视图模型中添加参数，可以传递给前台页面
        mv.addObject("username",username);
        return mv;
    }
}
